import request from '@/utils/http/request'
// import {getRefreshToken} from '@/utils/auth'
import {UserLoginVO} from '@/types'

export interface CodeImgResult {
    captchaOnOff: boolean
    img: string
    uuid: string
}

export interface SmsCodeVO {
    mobile: string
    scene: number
}

export interface SmsLoginVO {
    mobile: string
    code: string
}

// 登录
export const loginApi = async (data: UserLoginVO) => {
    return await request({
        url: '/system/auth/login', data,
        method: 'POST'
    })
}

// 刷新访问令牌
// export const refreshToken = () => {
//     return request({
//         url: '/system/auth/refresh-token?refreshToken=' + getRefreshToken(),
//         method: 'POST'
//     })
// }

// 使用租户名，获得租户编号
export const getTenantIdByNameApi = async (name: string) => {
    return await request({
        url: '/system/tenant/get-id-by-name?name=' + name,
        method: 'GET'
    })
}

// 登出
export const loginOutApi = async () => {
    return await request({
        url: '/system/auth/logout',
        method: 'DELETE'
    })
}

// 获取用户权限信息
export const getInfoApi = async () => {
    return await request({
        url: '/system/auth/get-permission-info',
        method: 'GET'
    })
}

// 路由
export const getAsyncRoutesApi = async () => {
    return await request({
        url: '/system/auth/list-menus',
        method: 'GET'
    })
}

//获取登录验证码
export const sendSmsCodeApi = async (data: SmsCodeVO) => {
    return await request({
        url: '/system/auth/send-sms-code', data,
        method: 'POST'
    })
}

// 短信验证码登录
export const smsLoginApi = async (data: SmsLoginVO) => {
    return await request({
        url: '/system/auth/sms-login', data,
        method: 'POST'
    })
}

// 社交授权的跳转
export const socialAuthRedirectApi = async (type: number, redirectUri: string) => {
    return await request({
        url: '/system/auth/social-auth-redirect?type=' + type + '&redirectUri=' + redirectUri,
        method: 'GET'
    })
}
// 获取验证图片  以及token
export const getCodeApi = async (data: any) => {
    return await request({
        url: 'system/captcha/get', data,
        method: 'POST'
    })
}

// 滑动或者点选验证
export const reqCheckApi = async (data: any) => {
    return await request({
        url: 'system/captcha/check', data,
        method: 'POST'
    })
}
